package com.codi.bus.core.service;

import com.codi.base.exception.BaseAppException;
import com.codi.bus.core.domain.User;
import com.codi.bus.core.domain.UserBank;
import com.codi.bus.core.domain.UserSession;
import com.codi.bus.core.domain.ext.UserExt;
import com.codi.bus.core.resultModel.*;
import com.codi.bus.core.service.model.BankModel;
import com.codi.bus.core.vo.OrganProfileVo;
import com.codi.bus.core.vo.OrganProfileVoNew;
import com.codi.bus.core.vo.UserBankVo;
import com.codi.bus.core.vo.UserProfileVo;
import com.codi.bus.exception.BaseException;

import java.util.List;

public interface UserService {
    /**
     * 开户
     * 2017.7.1之后不再使用 shi.pengyan 2017-6-19 16:08:11
     *
     * @param entity
     * @param bankEntity
     * @return
     * @throws BaseException
     */
    @Deprecated
    AccountOpenResult openAccount(User entity, UserBank bankEntity) throws BaseException;

    /**
     * 开户服务
     * 2017.7.1 之后使用
     *
     * @param entity
     * @param userProfileVo
     * @param bankEntity
     * @return
     * @throws BaseException
     * @author shi.pengyan
     * @date 2017-6-19 16:09:34
     */
    AccountOpenResult openAccountNew(User entity, UserProfileVo userProfileVo, UserBank bankEntity) throws BaseException;

    void update(User entity) throws BaseException;

    Boolean checkMobile(String mobile) throws BaseException;

    Boolean checkVerifyCode(String mobile, String authCode, String bizCode) throws BaseException;

    Boolean checkIDCard(String idCard) throws BaseException;

    Boolean checkBankNo(String bankNo, String capitalMode) throws BaseException;

    String registerAccount(User entity, UserSession sessionEntity, String ip) throws BaseException;

    LoginResult login(String loginName, String password, String deviceId, String channelId, String ip) throws BaseException;
    BaseResult h5Login(String loginName, String password) throws BaseException;
    String generateToken(Long userId, String deviceId, String channelId, String ip) throws BaseException;

    ValidateTokenResult validateToken(String token, String deviceId) throws BaseException;

    ValidateTokenResult validateToken(String token, String ip, String deviceId, boolean generateNewToken) throws BaseException;

    CardBinResult validateCardInfo(String cardNo) throws BaseException;

    User getUser(Long userId) throws BaseException;

    User getUser(String mobile) throws BaseException;

    User getUserByToken(String token) throws BaseException;

    PaySignResult paySign_Step_One(User entity, UserBank bankEntity) throws BaseException;

    PaySignResult paySign_Step_Two(User entity, UserBank bankEntity, String originalSerialNo, String smsSerialNo,
                                   String mobileCode) throws BaseException;

    BaseResult update_password(Long user_id, String old_password, String new_password);

    // 新增交易账号
    AccountOpenResult addAccount(Long userId, String idNo, String tradePassword, String userName, String bankCode,
                                 String bankNo, String bankName, String mobile, String capitalMode, String externalProtocolNo, String vcBranchbank, String vcBankName)
        throws BaseException;

    // 变更主交易账号并且解绑银行卡
    BaseResult repalceAndCloseTradeAccount(long userId, String password, String bankCard, String capitalMode, Long profileId)
        throws BaseException;

    // 交易账号销户
    BaseResult closeAccount(String tradeAccount, String taAccount, String password) throws BaseException;

    // 变更主交易账号
    BaseResult replaceAccount(String newMainAccount, String taAccount, String password, String originalMainAccount)
        throws BaseException;

    BaseResult resetLoginPassword(String mobile, String verification_code, String new_passwd) throws BaseException;

    BaseResult resetTradePassword(Long userId, String id_card, String mobile, String verification_code, String new_passwd) throws BaseException;

    BaseResult verifyVerificationCode(String mobile, String code, String bizCode);

    BaseResult verifyUserIdAndMobile(String id_card, String mobile, String verification_code);

    /**
     * 判断普通用户是否开户
     *
     * @param userId
     * @return
     */
    boolean checkAccountOpen(Long userId, Long profileId);


    /**
     * 创建机构用户
     *
     * @param entity
     * @return
     * @throws BaseException
     */
    User registerOrganAccount(User entity) throws BaseException;

    /**
     * 机构用户添加资料
     *
     * @param userId
     * @param organProfileVo
     * @param userBankVo
     * @return 4.6.0版本以后弃用
     */
    @Deprecated
    BaseResult addOrganProfile(Long userId, OrganProfileVo organProfileVo, UserBankVo userBankVo) throws BaseAppException;


    /**
     * 机构用户添加资料（新） 该接口已移动至  OrganAccountService
     *
     * @param userId
     * @param organProfileVoNew
     * @param userBankVo
     * @return
     * @throws BaseAppException
     */
    BaseResult addOrganProfileNew(Long userId, OrganProfileVoNew organProfileVoNew, UserBankVo userBankVo) throws BaseAppException;

    /**
     * 更新机构账户（用于机构开户，审核失败，再发起的操作）
     *
     * @param userId
     * @param organProfileVo
     * @param userBankVo
     * @return
     * @throws BaseException
     */
    @Deprecated
    AccountOpenResult updateOrganAccount(Long userId, OrganProfileVo organProfileVo, UserBankVo userBankVo) throws BaseException, BaseAppException;


    /**
     * 该接口已移动至  OrganAccountService
     *
     * @param userId
     * @param organProfileVoNew
     * @param userBankVo
     * @return
     * @throws BaseException
     * @throws BaseAppException
     */
    AccountOpenResult updateOrganAccountNew(Long userId, OrganProfileVoNew organProfileVoNew, UserBankVo userBankVo) throws BaseException, BaseAppException;

    /**
     * 查询机构信息
     *
     * @param userId
     * @return
     */
    @Deprecated
    OrganInfoResult qryOrganInfo(Long userId) throws BaseAppException;

    /**
     * 该接口已移动至  OrganAccountService
     *
     * @param profileId
     * @return
     * @throws BaseAppException
     */
    OrganInfoResult qryOrganInfoByProfileId(Long profileId) throws BaseAppException;


    /**
     * 机构用户登录
     *
     * @param userId
     * @param password
     * @param deviceId
     * @param channelId
     * @param ip
     * @return
     * @throws BaseException 4.6.0版本以后弃用
     */
    @Deprecated
    LoginResult login4Organ(Long userId, String password, String deviceId, String channelId, String ip) throws BaseException, BaseAppException;


    /**
     * 该接口已移动至  OrganAccountService
     *
     * @param mobile
     * @param password
     * @param deviceId
     * @param channelId
     * @param ip
     * @return
     */
    LoginResult login4OrganNew(String mobile, String password, String deviceId, String channelId, String ip);

    /**
     * 更新手机号（设计不是很好）
     *
     * @param userId
     * @param authCode
     * @param newMobile
     * @param authCode2
     * @return
     */
    LoginResult changeMobile(Long userId, String authCode, String newMobile, String authCode2) throws BaseAppException;


    /**
     * 查询机构用户审核的状态
     *
     * @param userId
     * @return
     */
    AccountOpenResult queryOrgState(Long userId, Long profileId);

    /**
     * 重置机构登陆密码
     *
     * @param mobile
     * @param verification_code
     * @param new_passwd
     * @return
     * @throws BaseException
     */
    BaseResult resetOrgLoginPassword(String mobile, String verification_code, String new_passwd) throws BaseException;

    /**
     * 重置机构用户密码
     * 该接口已移动至  OrganAccountService
     *
     * @param userId
     * @param authCode
     * @param newTradePwd 4.6.0版本后弃用
     * @return
     */
    @Deprecated
    BaseResult resetOrgTradePwd(Long userId, Long profileId, String authCode, String newTradePwd);

    /**
     * 判断机构用户是否已经成功开户
     *
     * @param userId
     * @return
     */
    Boolean checkOrgAcctIsOpen(Long userId);

    Boolean checkOrgAcctStatus(Long profileId);
    /**
     * 检查机构用户状态，发送短信
     */
    void checkOrgAcctStateAndSMS();

    /**
     * 用户列表
     *
     * @param pageIndex
     * @param pageSize
     * @param user
     * @return
     */
    List<User> queryList(Integer pageIndex, Integer pageSize, UserExt user);

    /**
     * 获得邀请用户列表
     */
    List<User> getInviteUserInfos(Integer pageIndex, Integer pageSize, Long userId);

    /**
     * 用户总数
     *
     * @param user
     * @return
     */
    Integer queryListCount(UserExt user);

    BankModel getChangeBranch(Long userId);

    /**
     * 更新所有用户系统消息个数
     */
    void updateAllUsersSysMessageCounts();

    void updateAllUsersSys();

    void updateChinaTax(Long userId);
}
